﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using Factonomy.AzureUtility.Core;
using Factonomy.AzureUtility.Core.Storage;
using Factonomy.AzureUtility.Core.StorageHelpers;

namespace Factonomy.AzureUtility.Dialogs
{
    /// <summary>
    /// Interaction logic for Settings.xaml
    /// </summary>
    public partial class Settings : Window
    {
        public Settings()
        {
            InitializeComponent();

            this.uiTextboxRootPath.Text = Config.Instance.Rootpath;
        }

        private void uiButtonRootPath_Click(object sender, RoutedEventArgs e)
        {
            using (System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog())
            {
                dialog.ShowNewFolderButton = false;
                dialog.RootFolder = Environment.SpecialFolder.MyComputer;
                dialog.SelectedPath = this.uiTextboxRootPath.Text;

                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    this.uiTextboxRootPath.Text = dialog.SelectedPath.ToLower();
                }
            }
        }

        private void uiButtonCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void uiButtonOk_Click(object sender, RoutedEventArgs e)
        {
            Config.Instance.Rootpath = this.uiTextboxRootPath.Text;
            this.Close();
        }
    }
}
